<?php

require "fpdf.php";

class PDF extends FPDF
{
}

$pdf=new PDF('P', 'mm', 'Letter');
$pdf->SetMargins(20, 18);
$pdf->AliasNbPages();
$pdf->AddPage();


//TITULO
$pdf->SetTextColor(0x00, 0x00, 0x00);
$pdf->SetFont("arial", "b", 9);
$pdf->Cell(0, 5, "Ventas", 0, 1, 'C');

//CONEXIÓN

mysql_connect("localhost","root","");
mysql_select_db("allsport");

//Mostramos datos
$pdf->Ln();
$pdf->Cell(30, 5, "CODIGO VENTA", 1, 0, 'C');
$pdf->Cell(20, 5, "Fecha", 1, 0, 'C');
$pdf->Cell(20, 5, "Precio", 1, 0, 'C');
$pdf->Cell(20, 5, "Dni", 1, 0, 'C');
$pdf->Cell(30, 5, "Nombre", 1, 0, 'C');
$pdf->Cell(20, 5, "Cantidad", 1, 0, 'C');
$pdf->Cell(30, 5, "REFERENCIA", 1, 0, 'C');


$pdf->Ln();


$sql="SELECT * FROM ventas ";
$rec=mysql_query($sql);
while($row=mysql_fetch_array($rec)){
$pdf->Cell(30, 5, $row['codigo_venta'],1,0, 'C');
$pdf->Cell(20, 5, $row['fecha'],1,0, 'C');
$pdf->Cell(20, 5, $row['precio'],1,0, 'C');
$pdf->Cell(20, 5, $row['dni'],1,0, 'C');
$pdf->Cell(30, 5, $row['nombre'],1,0, 'C');
$pdf->Cell(20, 5, $row['cantidad'],1,0, 'C');
$pdf->Cell(30, 5, $row['codigo_p'],1,0, 'C');
$pdf->Ln();
}

$pdf->Output(/**/);

?>